import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set from '@dfeidao/atom-web/local/set';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
// tslint:disable-next-line: ordered-imports
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import show from '@dfeidao/atom-web/ui/show';
import p001 from './p001';

export default async function a001(fd: IFeidaoAiBrowserComponent,arr: string) {
	// todo
	show(fd.data.node);
	const xuanze=fd.data.node.querySelector<HTMLDivElement>('[data-id="panduan"]');
	set_node_cls(xuanze,'display-n',false);
	const res = await nodejs<{dt: Array<{question_bank_type: string,right_answer: string}>}>('question-bank/zj-000006/s001',{
		filter:{
			question_no:arr
		}
	});
	set (fd,'arr',arr);

	let a="";
	for (let c=0;c < res.dt.length;c++) {
		a += res.dt[c].right_answer;
	 }
	render(fd,res.dt,p001,'p001','replace');
	const Y=fd.data.node.querySelector<HTMLInputElement>('[data-id="Y"]');
	const N=fd.data.node.querySelector<HTMLInputElement>('[data-id="N"]');
	// tslint:disable-next-line: triple-equals
	if (a === "Y") {
		Y.checked = true;
	} else {
		N.checked = true;
	}
}
